<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>欢迎来到登录页面</h1>
<div>
    用户名：<input type="text" id="ipt-username" name="username"><br/>
    密码：<input type="password" id="ipt-pwd" name="password"><br/>
    <button id="btn-login">登录</button>
    <button>重置</button>
</div>
</body>
</html>
<!-- ./   ../   -->
<script src="./js/axios.min.js"></script>
<script>
    //找元素 找对象
    const loginBtObj = document.getElementById("btn-login");
    //绑定事件
    loginBtObj.onclick = function () {
        // alert(111)
        //获取 input输入的值
        //找到这个元素对象
        const userName = document.getElementById("ipt-username").value;
        const pwd = document.getElementById("ipt-pwd").value;
        //发网络axios请求
        //axios.post(url,data)
        const url = "/user/login";
        const data = {
            "username" : userName,
            "password" : pwd
        }
        axios.post(url , data)
            .then(function (res) {
                const responseBody = res.data
                if (responseBody.code === 200){
                    alert("登录成功!")
                }
            })
    }

</script>

